<template>
  <div id="audit-table">
    <el-table
      :data="tableData"
      border
      class="inventory_table"
      :header-cell-style="{ padding: '0px', background: '#F2F3F7' }"
      :row-class-name="tabRowClassName"
    >
      <el-table-column width="60" align="center" type="index" label="序号">
        <template slot-scope="scope">
          {{ scope.$index + 1 }}
        </template>
      </el-table-column>
      <el-table-column align="center" label="审核人" prop="reviewName"> </el-table-column>
      <el-table-column align="center" label="审核意见" prop="reviewMind"> </el-table-column>
      <el-table-column align="center" label="审核结果" prop="reviewState">
        <template slot-scope="scope">
          <div>
            {{ scope.row.reviewState | reviewFilter }}
          </div>
        </template>
      </el-table-column>
      <el-table-column align="center" label="审核时间" prop="createTime"> </el-table-column>
    </el-table>
  </div>
</template>

<script>
export default {
  props: {
    state: {
      type: Number,
      default: 0
    },
    biddId: {
      type: Number,
      require: true
    }
  },
  data() {
    return {
      id: this.biddId,
      tableData: [],
      State: this.state
    }
  },
  mounted() {
    this.getData()
  },
  methods: {
    getData() {
      this.$https({
        method: 'post',
        url: '/bidding/listExamineInfo',
        data: {
          biddingId: this.id,
          reviewType: this.State
        }
      })
        .then(res => {
          if (res.code === 0) {
            this.tableData = res.data
          } else {
            this.$message.error(res.msg)
          }
        })
        .catch(err => {
          console.log(err)
        })
    },
    tabRowClassName({ row, rowIndex }) {
      let index = rowIndex + 1
      if (index % 2 == 0) {
        return 'warning-row'
      }
    }
  },
  filters: {
    reviewFilter(val) {
      switch (val) {
        case 0:
          return '未审核'
        case 1:
          return '审核通过'
        case 2:
          return '审核驳回'
        case 3:
          return '失效'
        default:
          break
      }
    }
  },
  watch: {
    state() {
      return (this.State = this.state)
    }
  }
}
</script>
<style lang="less" scoped>
#audit-table {
  padding: 5px;
}
</style>
